package com.zzh.wsss.controller;

import com.zzh.wsss.service.AdminLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
public class AdminLoginController {

    @Autowired
    AdminLoginService adminLoginService;


    @RequestMapping(value = "/adminLogin",method = RequestMethod.GET)
    private Map<String,Object> AdminLogin(String username, String password){

        Boolean success=adminLoginService.adminlogin(username,password);
        Map<String,Object> map=new HashMap<String, Object>();
        if(success==true)map.put("admin",adminLoginService.adminloginmsg(username));
        map.put("success",success);
        return map;
    }

    @RequestMapping(value = "/updataAdminPassword",method = RequestMethod.PUT)
    private Map<String,Object> updataAdminPassword(@RequestBody Map<String,String> map){
        Boolean success=adminLoginService.updatapassword(map.get("adminUsername"),map.get("oldpassword"),map.get("newpassword"));
        Map<String,Object> map1=new HashMap<String, Object>();
        map1.put("success",success);
        return map1;
    }

}
